﻿namespace Lilium
    
module String =

    let capitalize (s : System.String) = 
        if (System.String.IsNullOrWhiteSpace(s))
            then s
            else System.Char.ToUpper(s.Chars(0)).ToString() + s.Substring(1)

    // Patterns

    let (|EndsWith|_|) (suffix: string) (s : string) = 
        match s with
        | _ when s.EndsWith(suffix) -> Some (s.Remove(s.Length - suffix.Length))
        | _ -> None

    let (|StartsWith|_|) (prefix : string) (s: string) =
        match s with
        | _ when s.StartsWith(prefix) -> Some (s.Substring(prefix.Length))
        | _ -> None